import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:kotori和气球
 * User: wangxin
 * Date: 2024-09-26
 * Time: 17:39
 */
public class test1 {
    static int add(int x,int y){
        int i=y,sum=1;
        while(i>=1){
            if(i==y)sum=sum*x;
            else sum=sum*(x-1)%109;
            i--;
        }
        return sum;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别

        int n = in.nextInt();
        int m= in.nextInt();
        int ret = add(n,m);
        System.out.println(ret);

    }
}
